/**
 * 
 */
package server;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Ingo Philipp
 *
 * @version $Revision: 1.0 $
 */
public class Server {

    private Map<DBTypes, IDBConnector> driverMap = new HashMap<DBTypes, IDBConnector>();
    
    private static Server instance = null;

    public static Server getInstance() {
	if (instance == null) {

		    instance = new Server();

	}
	return instance;
    }

    private Server() {
	super();
    }

    private void initDbConnector(DBProperties dbProps) {
	try {
	    System.out.println(dbProps);
	    this.driverMap.get(dbProps.getDbType()).connect(dbProps);
	    System.out.println("Connection enabled");
	} catch (DBConException e) {
	    System.out.println("Connection failed");
	}
    }

    private void initDriverMap() {
	this.driverMap.put(DBTypes.MySQL, JdbcMySQLConnector.getInstance());
    }

    void initServer(DBProperties dbProps) throws DBConException {
	this.initDriverMap();
	this.initDbConnector(dbProps);
	/**
	 * TODO RMI INITIALIZATION HERE
	 */
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
	return "Server [driverMap=" + driverMap + "]";
    }
    
    

}
